import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/offices',
    name: 'Offices',
    component: () => import('@/views/Offices')
  },
  {
    path: '/plant',
    name: 'Plant',
    component: () => import('@/views/Plant')
  },
  {
    path: '/share',
    name: 'Share',
    component: () => import('@/views/Share')
  },
  {
    path: '/entrust',
    name: 'Entrust',
    component: () => import('@/views/Entrust')
  },
  {
    path: '/launch',
    name: 'Launch',
    component: () => import('@/views/Launch')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login')
  },
  {
    path: '/profile',
    name: 'Profile',
    component: () => import('@/views/Profile')
  },
  {
    path: '/profile/attention',
    name: 'Attention',
    component: () => import('@/views/Attention')
  },
  {
    path: '/profile/browse',
    name: 'Browse',
    component: () => import('@/views/Browse')
  },
  {
    path: '/profile/rental/:type',
    name: 'Rental',
    component: () => import('@/views/Rental')
  },
  {
    path: '/home/tradingArea/:id',
    name: 'TradingArea',
    component: () => import('@/views/TradingArea')
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import('@/views/Detail')
  },
  {
    path: '/search/:areaId?/:region_id?/:cate_id?/:build_id?',
    name: 'Search',
    component: () => import('@/views/Search')
  },
  {
    path: '/news',
    name: 'News',
    redirect: '/news/list',
    component: () => import('@/views/News'),
    children: [
      {
        // 当 /user/:id/profile 匹配成功，
        // UserProfile 会被渲染在 User 的 <router-view> 中
        path: 'list',
        component: () => import('@/views/News/pages/List')
      },
      {
        // 当 /user/:id/posts 匹配成功
        // UserPosts 会被渲染在 User 的 <router-view> 中
        path: 'detail/:id',
        component: () => import('@/views/News/pages/Detail')
      }
    ]
  }
]



const router = new VueRouter({
  routes
})

export default router
